<template>
  <div class="echarts">
    <div :style="{height:'620px',width:'100%'}" ref="myEchart"></div>
  </div>
</template>
<script>
  import echarts from "echarts";
    import '../../../node_modules/echarts/map/js/province/xinjiang.js'
  // import '../charts/china.js' // 引入中国地图数据
  export default {
    name: "ChartMap",
    props: ["userJson"],
    data() {
      return {
        chart: null
      };
    },
    mounted() {
      this.chinaConfigure();
    },
    beforeDestroy() {
      if (!this.chart) {
        return;
      }
      this.chart.dispose();
      this.chart = null;
    },
    methods: {
      chinaConfigure() {
        console.log(this.userJson)
        let myChart = echarts.init(this.$refs.myEchart); //这里是为了获得容器所在位置    
        window.onresize = myChart.resize;
        myChart.setOption({ // 进行相关配置
          backgroundColor: "#fff",
          tooltip: {}, // 鼠标移到图里面的浮动提示框
          dataRange: {
              x: 'left',
            y: 'bottom',
            splitList: [
                {start: 0, end: 0, label: '未建成',color: '#64f3ee'},
                {start: 1, end: 10, label: '已建成', color: '#11c2bc'},
            ],
            color: ['#eee', '#949fb1', '#f3ce85']
          },
          geo: { // 这个是重点配置区
            map: '新疆', // 表示新疆地图
            roam: false,
            label: {
              normal: {
                show: true, // 是否显示对应地名
                textStyle: {
                  color: 'rgba(0,0,0,0.4)'
                }
              }
            },
            layoutSize: 600,
            layoutCenter: ['50%', '50%'],
            itemStyle: {
              normal: {
                borderColor: 'rgba(0, 0, 0, 0.2)',
                borderColor: '#ffffff',//区域边框颜色
                areaColor:"#ffefd5",//区域颜色
              },
              emphasis: {
                areaColor: '#ffdead',
                shadowOffsetX: 0,
                shadowOffsetY: 0,
                shadowBlur: 20,
                borderWidth: 0,
                shadowColor: 'rgba(0, 0, 0, 0.5)'
              }
            }
          },
         
          series: [{
              type: 'scatter',
              coordinateSystem: 'geo' // 对应上方配置
            },
            {
              name: '平台数', // 浮动框的标题
              type: 'map',
              geoIndex: 0,
              data: [ 
                 {
                "name": "兰州市",
                "value": 5,
              },{
                "name": "嘉峪关市",
                "value": 1
              }, {
                "name": "金昌市",
                "value": 0
              }, {
                "name": "白银市",
                "value": 0
              }, {
                "name": "天水市",
                "value": 9
              }, {
                "name": "武威市",
                "value": 5
              },
               {
                "name": "张掖市",
                "value": 7
              },
               {
                "name": "平凉市",
                "value": 5
              },
               {
                "name": "酒泉市",
                "value": 5
              },
               {
                "name": "庆阳市",
                "value": 6
              },
               {
                "name": "定西市",
                "value": 7
              },
               {
                "name": "陇南市",
                "value": 1
              },
              {
                "name": "临夏州",
                "value": 8
              },
               {
                "name": "甘南州",
                "value": 0
              },
              
              ]
            }
          ]
        })
      }
    }
  }
</script>